//
//  SXPemoticonBtn.swift
//  weibo
//
//  Created by shixinPeng on 16/3/9.
//  Copyright © 2016年 shixinPeng. All rights reserved.
//

import UIKit

class SXPemoticonBtn: UIButton {
   
    //定义一个属性
    var emoticon:SXPEmoticonModel?{
        
        didSet{//应为有两种获取图片的模式,emoji是通过16进制数来转变为表情,而\png是通过名称来获取表情
            if let _ = emoticon?.emoji{//emoji图片
                setTitle(emoticon?.emoji, forState: .Normal)
                
                self.titleLabel?.font = UIFont.systemFontOfSize(35)
                
                setImage(nil, forState: .Normal)
                self.hidden = false
            }
            if let Opng = emoticon?.png{
                
                let indexPath = "\(emoticon!.imagPath!)/\(Opng)"
                //printLog(indexPath)
                
                self.setImage(UIImage(named: indexPath), forState: .Normal)
                
                
                setTitle(nil, forState: .Normal)
                self.hidden = false
                
            }
            
        }
    }
    
}
